// 用户第三方Token表

import { Entity, PrimaryGeneratedColumn, Column, PrimaryColumn, ManyToOne, JoinColumn } from 'typeorm';
import { User } from './User';


@Entity()
export class BranchAccount {

    @PrimaryColumn({
        type: 'varchar',
        length: '255'
    })
    userId!: string;

    @PrimaryColumn({
        type: 'varchar',
        length: '255'
    })
    brand!: string;

    @Column({
        type: 'varchar',
        length: '255'
    })
    token!: string;

    @Column({
        type: 'int'
    })
    expiresInHour!: number;

    @Column({
        type: 'timestamp' // 使用 timestamp 类型
    })
    expiresAt!: Date; // 将类型改为 Date

   @ManyToOne(() => User, user => user.accessTokens, {
    onDelete: 'CASCADE'
  })
    @JoinColumn({ name: 'userId' }) // 显式外键列
  user!: User;
}
